<!DOCTYPE html>
<html lang="">

<head>
	<meta name="generator" content="Hugo 0.73.0" />
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="author" content="Ap Chen ">
<meta name="description" content="网络层总结 虚电路网络、数据报网络 被路由协议、路由协议、特色协议 由解决网络地址危机、日常运营为主线牵出特色协议 两网络狂想曲 虚电路网络 数据报网络" />
<meta name="keywords" content="blog" />
<meta name="robots" content="noodp" />

<link rel="canonical" href="https://fziks.gitee.io/notes/computer-network/5.%E7%BD%91%E7%BB%9C%E5%B1%82%E6%80%BB%E7%BB%93/" />

<meta itemprop="name" content="4.网络层">
<meta itemprop="description" content="网络层总结 虚电路网络、数据报网络 被路由协议、路由协议、特色协议 由解决网络地址危机、日常运营为主线牵出特色协议 两网络狂想曲 虚电路网络 数据报网络">
<meta itemprop="datePublished" content="2020-04-30T00:00:00&#43;00:00" />
<meta itemprop="dateModified" content="2020-04-30T00:00:00&#43;00:00" />
<meta itemprop="wordCount" content="1123">



<meta itemprop="keywords" content="cn,notes," />
<meta property="og:title" content="4.网络层" />
<meta property="og:description" content="网络层总结 虚电路网络、数据报网络 被路由协议、路由协议、特色协议 由解决网络地址危机、日常运营为主线牵出特色协议 两网络狂想曲 虚电路网络 数据报网络" />
<meta property="og:type" content="article" />
<meta property="og:url" content="https://fziks.gitee.io/notes/computer-network/5.%E7%BD%91%E7%BB%9C%E5%B1%82%E6%80%BB%E7%BB%93/" />
<meta property="article:published_time" content="2020-04-30T00:00:00+00:00" />
<meta property="article:modified_time" content="2020-04-30T00:00:00+00:00" />

<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="4.网络层"/>
<meta name="twitter:description" content="网络层总结 虚电路网络、数据报网络 被路由协议、路由协议、特色协议 由解决网络地址危机、日常运营为主线牵出特色协议 两网络狂想曲 虚电路网络 数据报网络"/>


<link rel="apple-touch-icon" sizes="60x60" href="https://fziks.gitee.io/icons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="https://fziks.gitee.io/icons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="https://fziks.gitee.io/icons/favicon-16x16.png">
<link rel="manifest" href="https://fziks.gitee.io/icons/site.webmanifest">
<link rel="mask-icon" href="https://fziks.gitee.io/icons/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="https://fziks.gitee.io/icons/favicon.ico">
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-config" content="/icons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">

<title>4.网络层</title>


<link rel="stylesheet" href="//at.alicdn.com/t/font_1559566_wk214kwa2dn.css">


    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.css" integrity="sha384-zB1R0rpPzHqg7Kpt0Aljp8JPLqbXI3bhnPWROx27a9N0Ll6ZP/+DiW/UqRcLbRjq" crossorigin="anonymous">



    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.css" integrity="sha256-WAgYcAck1C1/zEl5sBl5cfyhxtLgKGdpI3oKyJffVRI=" crossorigin="anonymous" />
    
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.2/animate.css" integrity="sha256-a2tobsqlbgLsWs7ZVUGgP5IvWZsx8bTNQpzsqCSm5mk=" crossorigin="anonymous" />
    
   <link href="https://stackpath.bootstrapcdn.com/bootswatch/4.4.1/materia/bootstrap.min.css" rel="stylesheet" integrity="sha384-1tymk6x9Y5K+OF0tlmG2fDRcn67QGzBkiM3IgtJ3VrtGrIi5ryhHjKjeeS60f1FA" crossorigin="anonymous">
    
    
    <link rel="stylesheet" href="https://fziks.gitee.io/sass/main_cdn.min.270b43bb8631af4497ed45b90db42c517e86c9511418de9152f134d02ed32b87.min.2192baea245cf318085511589e62bfbdb3fbe4fb0eef718f1be9af91c10542ce.css" integity="sha256-IZK66iRc8xgIVRFYnmK/vbP75PsO73GPG&#43;mvkcEFQs4=">

</head>

<body style="overflow-x: unset;">
	<div class="container-fluid">
		<div class="row d-print-block">
			<div class="col-12 col-md-3 col-lg-2 bd-sidebar d-print-none">
				<div class="d-flex mt-3 border-bottom">
        <span class="navbar-brand w-100" style="display: grid;">
            <small>
                <a href="https://fziks.gitee.io/" class="text-black-50">
                    <i class="iconfont icon-back-arrow-"></i>
                </a>
                Ap Chen's
            </small>
            <a class="text-dark" href="https://fziks.gitee.io/notes/">
                Notes
            </a>
        </span>
        <button class="btn btn-link text-dark d-md-none p-0 ml-3" type="button" data-toggle="collapse"
            data-target="#bd-docs-nav" aria-controls="bd-docs-nav" aria-expanded="true"
            aria-label="Toggle docs navigation">
            <i class="fad fa-bars"></i>
        </button>
    </div>
				<nav id="bd-docs-nav" class="collapse bd-links">
    
    
    
    <div class="bd-toc-item active bg-light">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/computer-network/">
            <i class="iconfont icon-back-arrow-reverse"></i>
            计算机网络
        </a>
        <ul class="nav bd-sidenav">
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/computer-network/2.%E7%89%A9%E7%90%86%E5%B1%82/">2.物理层</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/computer-network/3.%E6%95%B0%E6%8D%AE%E9%93%BE%E8%B7%AF%E5%B1%82/">3.数据链路层</a>
            </li>
            
            
            
            <li class="active">
                <a href="https://fziks.gitee.io/notes/computer-network/5.%E7%BD%91%E7%BB%9C%E5%B1%82%E6%80%BB%E7%BB%93/">
                    <i class="fad fa-chevron-right mr-1"></i>
                    4.网络层
                </a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/computer-network/4.%E4%BC%A0%E8%BE%93%E5%B1%82%E6%80%BB%E7%BB%93/">5.传输层</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/computer-network/ripects/">RIP OSPF BGP</a>
            </li>
            
            
            
            <li>
                <a href="https://fziks.gitee.io/notes/computer-network/%E5%87%A0%E4%B8%AA%E6%A6%82%E5%BF%B5%E7%BB%86%E8%8A%82/">几个概念细节</a>
            </li>
            
            
        </ul>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/operating-system/">
            
            
                <span class="icontext">S</span>
            
            
            操作系统
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/database/">
            
            
                <span class="icontext">S</span>
            
            
            数据库
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/cs50-introduction-to-computer-science/">
            
            
                <span class="icontext">S</span>
            
            
            CS50 MIT
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/advanced-programming/">
            
            
                <span class="icontext">A</span>
            
            
            高级程序设计
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/deep-learning/">
            
            
                <span class="icontext">O</span>
            
            
            深度学习基础
        </a>
    </div>
    
    
    
    <div class="bd-toc-item">
        <a class="bd-toc-link" href="https://fziks.gitee.io/notes/%E6%96%87%E7%8C%AE%E7%AE%A1%E7%90%86%E4%B8%8E%E4%BF%A1%E6%81%AF%E5%88%86%E6%9E%90/">
            
            
                <span class="icontext">O</span>
            
            
            文献管理与信息分析
        </a>
    </div>
    
    
</nav>
			</div>
			<div class="col-12 col-md-9 col-lg-10 d-print-block">
				<div class="row d-print-block">
					<main class="col-12 col-md-10 col-lg-9 py-md-3 pl-md-5 bd-content d-print-block" role="main">
						<div id="title" class="my-4 border-bottom">
							<span>计算机网络</span>
							<h2>4.网络层</h2>
							<footer>
								<span>
									<i class="iconfont icon-NewFile mr-2"></i>
									2020-04-30 08:00 CST
								</span> <br />
								<span>
									<i class="iconfont icon-modify mr-2"></i>
									2020-04-30 08:00 CST
								</span> <br />
								<span>
									<i class="iconfont icon-copyright mr-2"></i>
									CC BY-NC 4.0
								</span>
							</footer>
						</div>
						<div id="content" class="hl-h2">
							
							
							
							
							
							
							
							
							
							
							
							
							<h1 id="网络层总结">网络层总结<a href="#网络层总结" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h1>
<p>虚电路网络、数据报网络</p>
<p>被路由协议、路由协议、特色协议</p>
<p>由解决网络地址危机、日常运营为主线牵出特色协议</p>
<h2 id="两网络狂想曲">两网络狂想曲<a href="#两网络狂想曲" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>虚电路网络</li>
<li>数据报网络</li>
</ul>
<h2 id="三协议协奏曲">三协议协奏曲<a href="#三协议协奏曲" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ul>
<li>被路由协议：
<ul>
<li>IP协议（IPv4、IPv6）
<ul>
<li>地址（定位目的机）</li>
<li>分组（封装）</li>
</ul>
</li>
</ul>
</li>
<li>路由选择协议：
<ul>
<li>距离矢量路由选择协议（eg. RIP）</li>
<li>链路状态路由选择协议（eg. OSPF）</li>
</ul>
</li>
<li>特色协议
<ul>
<li>ARP</li>
<li>ICMP</li>
<li>CIDR</li>
<li>NAT</li>
</ul>
</li>
</ul>
<h2 id="ipv4协议">IPv4协议<a href="#ipv4协议" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ol>
<li><strong>地址</strong>32位二进制，点分十进制表示，由ICANN机构分配</li>
<li><strong>网络地址</strong>早期分为A、B、C、D（组播）、E（科研）五大类</li>
<li>6种<strong>保留地址</strong>：非正常、默认目的、泛洪广播、本机、网络地址、广播地址</li>
<li><strong>寻址</strong>由IP和MAC地址协作</li>
<li>分组<img src="C:%5CUsers%5CCap%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20200530224547821.png" alt="image-20200530224547821"></li>
</ol>
<h2 id="子网掩码">子网掩码<a href="#子网掩码" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ol>
<li>一种了解网络规模的设定，一路分配给爷爷爸爸儿子孙子。（子网划分与超网构造共能缓解分配危机）</li>
<li>目的IP地址 &amp; 子网掩码=目的网络地址 （ 通过对目的IP地址和子网掩码 “与” 运算得到目的网络地址）</li>
<li>从主机号借位（最少给主机号留2位），剩下主机号为子网规模</li>
<li>设置规则： “1”必须连续、“0”不能在“1”前面</li>
</ol>
<h2 id="ipv6协议">IPv6协议<a href="#ipv6协议" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<ol>
<li><strong>地址</strong>128位二进制，冒分十六进制表示，340涧个（涧是10^36）</li>
<li><strong>网络地址</strong>分为 单播、组播、任播 ；（注意没有了广播！）</li>
<li>6种<strong>特殊地址</strong><img src="C:%5CUsers%5CCap%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20200530224403949.png" alt="image-20200530224403949"></li>
<li>IPv6与IPv4的改进比较</li>
<li>分组<img src="C:%5CUsers%5CCap%5CAppData%5CRoaming%5CTypora%5Ctypora-user-images%5Cimage-20200530224714204.png" alt="image-20200530224714204"></li>
<li>IPv4-&gt;IPv6
<ul>
<li>双协议栈</li>
<li>隧道技术</li>
<li>翻译、转换</li>
</ul>
</li>
</ol>
<h2 id="路由">路由<a href="#路由" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<p>静态、直连、动态</p>
<h2 id="路由选择协议">路由选择协议<a href="#路由选择协议" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<h3 id="距离矢量路由选择协议-dv">距离矢量路由选择协议 DV<a href="#距离矢量路由选择协议-dv" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<p>维护、交换、更新</p>
<h3 id="链路状态路由选择协议-ls">链路状态路由选择协议 LS<a href="#链路状态路由选择协议-ls" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<p>发现、设置、构造、发送、计算</p>
<p>例子：</p>
<h3 id="rip">RIP<a href="#rip" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<p>基于距离矢量路由选择的协议。</p>
<ol>
<li>最大的好处是<strong>简单</strong></li>
<li>设计思路：对于每个路由器拥有的两个向量的维护、交换、更新</li>
<li><strong>交换</strong>全部路由表信息</li>
<li>只对相邻路由器交换</li>
<li>固定时间段就交换</li>
<li>多使用不可靠的UDP协议，为周期性的交换节约开销</li>
</ol>
<h3 id="ospf">OSPF<a href="#ospf" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<p>基于分布式的链路状态协议。自治区域内协议。负责建立链路状态数据库表</p>
<ol>
<li>收敛快、支持在大型网络中使用</li>
<li>发送与本路由器相邻的所有路由器的链路状态</li>
<li>向本自治系统中所有路由器以泛洪法<strong>发送</strong>信息</li>
<li>用代价衡量线路质量</li>
<li>仅链路状态发生变化时才发送消息</li>
<li>多使用灵活好、开销少的IP协议</li>
</ol>
<h3 id="bgp">BGP<a href="#bgp" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<p>基于路径向量路由选择协议。自治区域间协议。</p>
<ol>
<li>交换“可达性”信息</li>
<li>对不同自治系统的路由器之间发生<strong>交换</strong></li>
<li>寻找比较好而非最佳路径</li>
<li>自治系统之间的路由选择必须考虑有关策略性   （自治系统能否用AS替代？）</li>
<li>仅路由发生变化时才更新有变化部分</li>
<li>多使用可靠的TCP协议，保证次数较少的交换必达以节约开销</li>
</ol>
<h2 id="特色协议">特色协议<a href="#特色协议" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h2>
<h3 id="cidr">CIDR<a href="#cidr" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<p>缓解B类地址枯竭危机和控制缩减路由表开销</p>
<p><strong>聚合</strong>IP A类地址，使之<strong>按需分配</strong></p>
<p>结果：构成 超网</p>
<p>好处：隔离了路由翻动</p>
<h3 id="nat">NAT<a href="#nat" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<p>NAT作为IP地址连接私人地址的翻译桥梁</p>
<p>特点： 安全、破坏唯一、破坏IP网络无连接特性、违背协议分层、对协议限制（仅UDP、TCP）、影响网络抓包（无法改变数据字段的IP地址）、超载</p>
<h3 id="icmp">ICMP<a href="#icmp" class="anchor" aria-hidden="true"><i class="iconfont icon-link"></i></a></h3>
<p>报告网络差错、测网络，封装于IP分组中</p>
<p>应用：</p>
<ul>
<li>ping</li>
<li>tracert</li>
<li>PMTU</li>
</ul>

						</div>
					</main>
					<div class="d-none d-lg-block col-lg-3 bd-toc d-print-none">
						<div class="btn-group-vertical w-100 my-3">
    
    <a class="btn btn-outline-secondary text-dark w-100 p-2" href="https://list.html" target="_blank">
        <i class="iconfont icon-LC_icon_list_line"></i><br />待更新列表
    </a>
    

    
    <a class="btn btn-outline-secondary text-dark w-100 p-2" href="mailto:littlegreedy@qq.com"
        target="_blank">
        <i class="iconfont icon-discussion"></i><br />纠错与咨询
    </a>
    
    
    
    
        <a class="btn btn-outline-secondary text-dark w-100 p-2" href="#" onclick="window.print()">
            <i class="iconfont icon-dayin"></i><br />打印本页
        </a>
    
    
</div>
						<h4 class="card-title pb-0">目录</h4>
						<nav id="TableOfContents">
  <ul>
    <li><a href="#两网络狂想曲">两网络狂想曲</a></li>
    <li><a href="#三协议协奏曲">三协议协奏曲</a></li>
    <li><a href="#ipv4协议">IPv4协议</a></li>
    <li><a href="#子网掩码">子网掩码</a></li>
    <li><a href="#ipv6协议">IPv6协议</a></li>
    <li><a href="#路由">路由</a></li>
    <li><a href="#路由选择协议">路由选择协议</a>
      <ul>
        <li><a href="#距离矢量路由选择协议-dv">距离矢量路由选择协议 DV</a></li>
        <li><a href="#链路状态路由选择协议-ls">链路状态路由选择协议 LS</a></li>
        <li><a href="#rip">RIP</a></li>
        <li><a href="#ospf">OSPF</a></li>
        <li><a href="#bgp">BGP</a></li>
      </ul>
    </li>
    <li><a href="#特色协议">特色协议</a>
      <ul>
        <li><a href="#cidr">CIDR</a></li>
        <li><a href="#nat">NAT</a></li>
        <li><a href="#icmp">ICMP</a></li>
      </ul>
    </li>
  </ul>
</nav>
						
						
						<div id="disqus_thread"></div>
							<script>
							

							

							(function() { 
							var d = document, s = d.createElement('script');
							s.src = "https://"+"your site name on disqus"+".disqus.com/embed.js";
							s.setAttribute('data-timestamp', +new Date());
							(d.head || d.body).appendChild(s);
							})();
							</script>
							<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>                  
					  	</div>
						
					</div>
				</div>
			</div>
		</div>
	</div>

	<script
    src="https://code.jquery.com/jquery-3.4.1.min.js"
    integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo="
    crossorigin="anonymous"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script><script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/katex.min.js" integrity="sha384-y23I5Q6l+B6vatafAwxRu/0oK/79VlbSz7Q9aiSZUvyWYIYsd+qj+o24G5ZU2zJz" crossorigin="anonymous"></script>
<script defer src="https://cdn.jsdelivr.net/npm/katex@0.11.1/dist/contrib/auto-render.min.js" integrity="sha384-kWPLUVMOks5AQFrykwIup5lo0m3iMkkHrD0uJ4H5cjeGihAutqP0yW0J6dpFiVkI" crossorigin="anonymous"
onload="renderMathInElement(document.body);"></script>

<script type="text/javascript" src="https://fziks.gitee.io/custom.min.d3e1b7647f32dbe7e0140398739a26dad3f3470fc1eebe0741ef33668f1b7bd0b2917dc6efb9f0d9f1092b91dca502cab1b883863f02530133a8a8ef609926af.js" integrity="sha512-0&#43;G3ZH8y2&#43;fgFAOYc5om2tPzRw/B7r4HQe8zZo8be9CykX3G77nw2fEJK5HcpQLKsbiDhj8CUwEzqKjvYJkmrw=="></script>
<script type="text/javascript">

document.addEventListener("DOMContentLoaded", function () {
    renderMathInElement(
        document.body, {
            delimiters: [
                {
                    left: "$$",
                    right: "$$",
                    display: true
                },
                {
                    left: "\\[",
                    right: "\\]",
                    display: true
                },
                {
                    left: "$",
                    right: "$",
                    display: false
                },
                {
                    left: "\\(",
                    right: "\\)",
                    display: false
                }
            ],
            strict: false
        }
    );
});


$(document).on('click', 'a[href^="#"]', function (event) {
    event.preventDefault();

    $('html, body').animate({
        scrollTop: $($.attr(this, 'href')).offset().top
    }, 500);
});
</script>




</body>

</html>